<?php

class FileValidation{
	
	private $key;
	private $app;
	
	public function __construct($app, $key){
		$this->key = $key;
		$this->app = $app;
	}
	
	public function getFile($hash){
		$ch = curl_init(URL_FILE_VALIDATION."/file/view/".$this->app.'/'.$hash);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		$data = curl_exec($ch);
		return ($data);
	}
	
	public function sendFile($file){
		$ch = curl_init(URL_FILE_VALIDATION."/file/add");
		$fields = array(
			'APPID' => $this->app,
			'KEY' => $this->key,
			'FILE' => '@'.$file
		);
		curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
		$data = json_decode(curl_exec($ch), true);
		return $data;
	}
	
}